home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Auge 4000 / Auge 4000 #47 (1990-06-22)(Amiga User Gruppe Einzugsgebiet 4000).zip / Auge 4000 #47 (1990-06-22)(Amiga User Gruppe Einzugsgebiet 4000).adf / arp-pro1.3 / INCLUDE / arpbase.i < prev   
Text File  |  1990-06-22  |  33KB  |  953 lines

  1.     IFND LIBRARIES_ARPBASE_I
  2. LIBRARIES_ARPBASE_I    SET    1
  3. ***********************************************************************
  4. *
  5. *    AmigaDOS Resource Project -- Library Include File (Assembler)
  6. *
  7. ***********************************************************************
  8. *
  9. *    History:
  10. *
  11. *    Version:    arpbase.i,v 34.00 02/27/88
  12. *
  13. *    Created by:    SDB
  14. *    Revised:    SDB (v 5.00 05/31/87)
  15. *            *---- Added meaningful alert numbers, revised macros,
  16. *            *---- updated ArpBase structure to reflect current state.
  17. *            *---- Added cheath's ASSIGN return codes as equates.
  18. *            *---- plus usual grunt work (revisions, lvo's, etc.)
  19. *            SDB (v6.04)
  20. *            cdh V7.0
  21. *            *---- added IntuiBase and GfxBase to ArpBase
  22. *            sdb V7.2
  23. *            *---- rearranged for more efficient lib code (ouch).
  24. *            *---- DosBase IntuiBase and GfxBase have *all* changed!
  25. *            *---- Few more alert #'s now get returned,
  26. *            *---- new GURU macro replaces provincial MYALERT.
  27. *            sdb v12 newstuff, see docs
  28. *            cdh V14 Added dos.library offsets, everybody moves!
  29. *            cdh V15 Added (volatile!) FindFirst etc offsets
  30. *            cdh V19 Added structs and constants for wildcards
  31. *            cdh V31 Final edit for V1.0 ARP 10/7/87
  32. *            sdb V31.00
  33. *                Final edits for release of developers materials.
  34. *                Massive changes to make this file correspond
  35. *                more closely with 'C' File.
  36. *
  37. *            SDB V32.00 Add Stuff for version 32, ASyncRun()
  38. *                Returns and data structures.
  39. *            SDB V32.01 Add ERROR_NO_CLI
  40. *            SDB V32.3 Add ResidentPrg stuff
  41. *            SDB V33.4 Final edits for release.
  42. *            SDB V35.0 PR_WANTSMESSAGE
  43. *            SDB Changes now tracked in arpheaders.log
  44. ***********************************************************************
  45. *
  46. *    Copyright (c) 1987/1988/1989, by Scott Ballantyne
  47. *
  48. *    The arp.library, and related code and files may be freely used
  49. *    by supporters of ARP.  Modules in the arp.library may not be
  50. *    extracted for use in independent code, but you are welcome to
  51. *    provide the arp.library with your work and call on it freely.
  52. *
  53. *    You are equally welcome to add new functions, improve the ones
  54. *    within, or suggest additions.
  55. *
  56. *    BCPL programs are not welcome to call on the arp.library.
  57. *    The welcome mat is out to all others.
  58. ***********************************************************************
  59.  
  60.     IFND EXEC_TYPES_I
  61.     INCLUDE "exec/types.i"
  62.     ENDC
  63.  
  64.     IFND EXEC_LIBRARIES_I
  65.     INCLUDE "exec/libraries.i"
  66.     ENDC
  67.  
  68.     IFND EXEC_LISTS_I
  69.     INCLUDE "exec/lists.i"
  70.     ENDC
  71.  
  72.     IFND EXEC_SEMAPHORES_I
  73.     INCLUDE "exec/semaphores.i"
  74.     ENDC
  75.  
  76.     IFND LIBRARIES_DOS_I
  77.     INCLUDE "libraries/dos.i"
  78.     ENDC
  79.  
  80.     IFND LIBRARIES_DOS_LIB_I
  81.     INCLUDE "libraries/dos_lib.i"
  82.     ENDC
  83.  
  84.  
  85.     STRUCTURE ArpBase,LIB_SIZE    ; Standard library node
  86.         APTR    DosRootNode    ; Copy of dl_Root
  87.         UBYTE    Flags        ; Not used, yet!
  88.         UBYTE    ESCChar     ; Character to be used for escaping
  89.         LONG    ArpReserved1    ; ArpLib's use only!!
  90.         CPTR    EnvBase     ; Dummy library for MANX compatibility
  91.         CPTR    DosBase     ; Cached DosBase
  92.         CPTR    GfxBase     ; Cached GfxBase
  93.         CPTR    IntuiBase    ; Cached IntuitionBase
  94.         STRUCT    ResLists,MLH_SIZE ; Resource trackers
  95.         ULONG    ResidentPrgList ; Resident Programs.
  96.         STRUCT    ResPrgProtection,SS_SIZE    ; protection for above
  97.         ULONG    SegList     ; Pointer to loaded libcode (a BPTR).
  98.         LABEL    ArpLib_SIZEOF
  99.  
  100. *--------------- Following is here only for compatibility with MANX,
  101. *--------------- don't use in new code!
  102.  
  103.     STRUCTURE EnvLib,LIB_SIZE    ; fake library for MANX
  104.         CPTR    EnvSpace    ; access only when Forbidden!
  105.         ULONG    EnvSize     ; size of environment
  106.         ULONG    EnvArpBase    ; for EXPUNGE
  107.         LABEL    EnvLib_SIZEOF
  108.  
  109. *---------- Flags bit definitions
  110. *
  111. * These are used in release 33.4, but not by the library code, instead,
  112. * individual programs which are affected check for these. Not ideal, but
  113. * such is life.
  114. *
  115. *-------------------------------------------------------
  116.  
  117.     BITDEF    ARP,WILD_WORLD,0    ; Mixed BCPL/Normal wildcards.
  118.     BITDEF    ARP,WILD_BCPL,1     ; Pure bcpl.
  119.  
  120. *----------- Rest of library style stuff
  121.  
  122. ArpName MACRO
  123.     dc.b    'arp.library',0
  124.     ds.w    0
  125.     ENDM
  126.  
  127. *---------- Current arp.library version.
  128.  
  129. ArpVersion EQU    39
  130.  
  131. *-------- Alert Object
  132. * The alert object is what you use if you really must return an alert
  133. * to the user.    You would normally OR this with another alert number from
  134. * the alerts.h file.  Generally, these should be NON deadend alerts.
  135. *
  136. * For example, if you can't open ArpLibrary:
  137. *
  138. *    GURU    AG_OpenLib!AO_ArpLib
  139. *----------------------------------------
  140.  
  141. AO_ArpLib    EQU    $00008036    ; alert object
  142.  
  143. *-------- Specific Alerts you can get from ArpLib. -----------*
  144.  
  145. AN_ArpLib    EQU    $03600000    ; alert number
  146. AN_ArpNoMem    EQU    $03610000    ; Arplibrary out of memory.
  147. AN_ArpInputMem    EQU    $03610002    ; No memory for input buffer.
  148. AN_ArpNoMakeEnv EQU    $83610003    ; No memory to make EnvLib
  149.  
  150. AN_ArpNoDOS    EQU    $83630001    ; Can't open DOS library
  151. AN_ArpNoGfx    EQU    $83630002    ; Can't open graphics
  152. AN_ArpNoIntuit    EQU    $83630003    ; Can't open intuition
  153. AN_BadPackBlues EQU    $83640000    ; Bad packet returned to SendPacket()
  154.  
  155. AN_Zombie    EQU    $83600003    ; AsyncRun() Exit code didn't.
  156.  
  157. AN_ArpScattered EQU    $83600002    ; Scatter loading not allowed for lib.
  158.  
  159. *---------- Tiny ALERT macro, assumes ExecBase is already in A6, also that you
  160. *---------- have nothing important in d7, also that you want to return immediately.
  161.  
  162. GURU    MACRO    * optional alert number
  163.     IFNC    '\1',''
  164.     move.l    #\1,D7
  165.     ENDC
  166.     jmp    _LVOAlert(a6)
  167.     ENDM
  168.  
  169. MYALERT MACRO * ancient compatibility
  170.     GURU    \1
  171.     ENDM
  172.  
  173. *------------- Library Vector Offsets.
  174.  
  175.  
  176. *
  177. * This macro is used to define the DOS offsets without redefining the symbols-
  178. *    To get the DOS symbols, INCLUDE dos_lib.i
  179. *
  180. LIBSKP    MACRO
  181. COUNT_LIB   SET     COUNT_LIB-LIB_VECTSIZE
  182.     ENDM
  183.  
  184.     LIBINIT
  185.  
  186.     LIBSKP    _LVOOpen
  187.     LIBSKP    _LVOClose
  188.     LIBSKP    _LVORead
  189.     LIBSKP    _LVOWrite
  190.     LIBSKP    _LVOInput
  191.     LIBSKP    _LVOOutput
  192.     LIBSKP    _LVOSeek
  193.     LIBSKP    _LVODeleteFile
  194.     LIBSKP    _LVORename
  195.     LIBSKP    _LVOLock
  196.     LIBSKP    _LVOUnLock
  197.     LIBSKP    _LVODupLock
  198.     LIBSKP    _LVOExamine
  199.     LIBSKP    _LVOExNext
  200.     LIBSKP    _LVOInfo
  201.     LIBSKP    _LVOCreateDir
  202.     LIBSKP    _LVOCurrentDir
  203.     LIBSKP    _LVOIoErr
  204.     LIBSKP    _LVOCreateProc
  205.     LIBSKP    _LVOExit
  206.     LIBSKP    _LVOLoadSeg
  207.     LIBSKP    _LVOUnLoadSeg
  208.     LIBSKP    _LVOGetPacket
  209.     LIBSKP    _LVOQueuePacket
  210.     LIBSKP    _LVODeviceProc
  211.     LIBSKP    _LVOSetComment
  212.     LIBSKP    _LVOSetProtection
  213.     LIBSKP    _LVODateStamp
  214.     LIBSKP    _LVODelay
  215.     LIBSKP    _LVOWaitForChar
  216.     LIBSKP    _LVOParentDir
  217.     LIBSKP    _LVOIsInteractive
  218.     LIBSKP    _LVOExecute
  219. ***
  220.     LIBDEF    _LVOPrintf        ; Print formatted data on current output.
  221.     LIBDEF    _LVOFPrintf        ; Print formatted data on file.
  222.     LIBDEF    _LVOPuts        ; Print string\n on stdout.
  223.     LIBDEF    _LVOReadLine        ; Get a line from stdin.
  224.     LIBDEF    _LVOGADS        ; Get args using template
  225.     LIBDEF    _LVOAtol        ; Convert Ascii to long int.
  226.     LIBDEF    _LVOEscapeString    ; Handle escapes in string.
  227.     LIBDEF    _LVOCheckAbort        ; Check for CNTRL-C
  228.     LIBDEF    _LVOCheckBreak        ; Check for CNTRL c d e or f
  229.     LIBDEF    _LVOGetenv        ; Get value of environment variable
  230.     LIBDEF    _LVOSetenv        ; Set value of environment variable
  231.     LIBDEF    _LVOFileRequest     ; Filename Requester
  232.     LIBDEF    _LVOCloseWindowSafely    ; Closes shared IDCMP window w/o GURU
  233.     LIBDEF    _LVOCreatePort        ; Create a message port
  234.     LIBDEF    _LVODeletePort        ; Delete a message port
  235.     LIBDEF    _LVOSendPacket        ; Send a dos packet
  236.     LIBDEF    _LVOInitStdPacket    ; initialize a standard packet
  237.     LIBDEF    _LVOPathName        ; Return Complete pathname of file/directory.
  238.     LIBDEF    _LVOAssign        ; Assign a logical device name
  239.     LIBDEF    _LVODosAllocMem     ; DOS compatible memory allocator
  240.     LIBDEF    _LVODosFreeMem        ; DOS compatible memory free-er
  241.     LIBDEF    _LVOBtoCStr        ; Copy a BCPL string to C string
  242.     LIBDEF    _LVOCtoBStr        ; Copy a C string to BCPL string
  243.     LIBDEF    _LVOGetDevInfo        ; Get pointer to head of DevInfo
  244.     LIBDEF    _LVOFreeTaskResList    ; Free Tracked resources for this task
  245.     LIBDEF    _LVOArpExit        ; Exit, freeing tracked resources.
  246.     LIBDEF    _LVOArpAlloc        ; Allocate memory with tracking
  247.     LIBDEF    _LVOArpAllocMem     ; Track AllocMem allocation
  248.     LIBDEF    _LVOArpOpen        ; Track open files
  249.     LIBDEF    _LVOArpDupLock        ; Track duped locks
  250.     LIBDEF    _LVOArpLock        ; Track allocated locks
  251.     LIBDEF    _LVORListAlloc        ; Like ArpAlloc for free reslist
  252.     LIBDEF    _LVOFindCLI        ; Get a process given a task number
  253.     LIBDEF    _LVOQSort        ; Quick Sort
  254.  
  255.     LIBDEF    _LVOPatternMatch    ; Match a string with a pattern (wildcards!)
  256.     LIBDEF    _LVOFindFirst        ; Search directory w/wildcards
  257.     LIBDEF    _LVOFindNext        ; Continue search w/wildcards
  258.     LIBDEF    _LVOFreeAnchorChain    ; Free mem from FindFirst/Next
  259.  
  260.     LIBDEF    _LVOCompareLock     ; Compare two disk locks
  261.  
  262.     LIBDEF    _LVOFindTaskResList    ; Find resource list for this task
  263.     LIBDEF    _LVOCreateTaskResList    ; Create a new nested task reslist
  264.     LIBDEF    _LVOFreeResList     ; Free an un-attached reslist
  265.     LIBDEF    _LVOFreeTrackedItem    ; Free a tracked item
  266.     LIBDEF    _LVOGetTracker        ; Get a tracker node
  267.  
  268.     LIBDEF    _LVOGetAccess        ; Lock access to a node
  269.     LIBDEF    _LVOFreeAccess        ; Allow resource to flush if lowmem
  270.  
  271.     LIBDEF    _LVOFreeDAList        ; Free a DosAllocmem list
  272.     LIBDEF    _LVOAddDANode        ; Add a node to a DA list
  273.     LIBDEF    _LVOAddDADevs        ; Add devices to a DA list
  274.  
  275.     LIBDEF    _LVOStrcmp        ; Compare two null-terminated strs
  276.     LIBDEF    _LVOStrncmp        ; Compare up to N chars
  277.     LIBDEF    _LVOToupper        ; Convert to UC
  278.     LIBDEF    _LVOSyncRun        ; Run program as subroutine
  279. * Added V32 of arp.library
  280.     LIBDEF    _LVOASyncRun        ; Run program in background
  281.     LIBDEF    _LVOLoadPrg        ; As for LoadSeg(), but searches Res&Path
  282.     LIBDEF    _LVOPreParse        ; Create tokenized PatternMatch string
  283. * V33
  284.     LIBDEF    _LVOStamptoStr        ; Date stamp to string
  285.     LIBDEF    _LVOStrtoStamp        ; Date string to stamp
  286.  
  287.     LIBDEF    _LVOObtainResidentPrg    ; Get a resident program
  288.     LIBDEF    _LVOAddResidentPrg    ; Add it
  289.     LIBDEF    _LVORemResidentPrg    ; Remove it
  290.     LIBDEF    _LVOUnLoadPrg        ; Check Sum code
  291.     LIBDEF    _LVOLMult        ; long mult
  292.     LIBDEF    _LVOLDiv        ; long division, signed
  293.     LIBDEF    _LVOLMod        ; long %
  294.  
  295.     LIBDEF    _LVOCheckSumPrg     ; Refresh checksum for resident code
  296.     LIBDEF    _LVOTackOn        ; Add A1 onto directory string A0
  297.     LIBDEF    _LVOBaseName        ; Get Filename from complete dir string
  298.     LIBDEF    _LVOReleaseResidentPrg    ; True if code is resident and was released.
  299.  
  300. * V36
  301.     LIBDEF    _LVOSPrintf
  302.     LIBDEF    _LVOGetKeywordIndex
  303.     LIBDEF    _LVOArpOpenLibrary
  304. ***
  305.     LIBDEF    _LVOArpAllocFreq
  306.  
  307. *---------- Return codes you can get from calling Assign:
  308.  
  309. ASSIGN_OK    EQU    0    ; Everything is cool and groovey
  310. ASSIGN_NODEV    EQU    1    ; "Physical" is not valid for assignment
  311. ASSIGN_FATAL    EQU    2    ; Something really icky happened
  312. ASSIGN_CANCEL    EQU    3    ; Tried to cancel something that won't cancel.
  313.  
  314. *--------- Size of buffer you need for ReadLine
  315.  
  316. MaxInputBuf    EQU    256
  317.  
  318. * Macro to declare things as unions:
  319.  
  320. UNION    MACRO    *name,maxsize
  321. UOFFSET SET    SOFFSET
  322. \1    EQU    SOFFSET
  323. SOFFSET SET    SOFFSET+\2
  324.     ENDM
  325. * member of union
  326.  
  327. UMEMB MACRO    * name
  328. \1    EQU    UOFFSET
  329.     ENDM
  330.  
  331. ******************************* File Requester *******************************
  332. ********************** Submit the following to FileRequest() *****************
  333. ******************************************************************************
  334.  
  335.     STRUCTURE FileRequester,0
  336.         CPTR    fr_Hail         ; Hailing text
  337.         CPTR    fr_File         ; *Filename array (FCHARS+1)
  338.         CPTR    fr_Dir            ; *Directory array (DSIZE+1)
  339.         CPTR    fr_Window        ; Window requesting or NULL
  340.         UBYTE    fr_FuncFlags        ; Set bitdef's below
  341.         UBYTE    fr_reserved1        ; Set to NULL
  342.         APTR    fr_Function        ; Func to call for wildcards
  343.         LONG    fr_reserved2        ; RESERVED
  344.         LABEL    fr_SIZEOF
  345.  
  346. *****************************************************************
  347. * The following are the equates for fr_FuncFlags. These bits tell
  348. * FileRequest() what your fr_UserFunc is expecting, and what FileRequest()
  349. * should call it for.
  350. *
  351. * You are called like so
  352. * fr_Function(Mask, Object)
  353. * ULONG Mask
  354. * CPTR    *Object
  355. *
  356. * The Mask is a copy of the flag value that caused FileRequest() to call
  357. * your function. You can use this to determine what action you need to
  358. * perform, and exactly what Object is, so you know what to do and
  359. * what to return.
  360. *
  361.     BITDEF    FR,DoWildFunc,7 ; Call me with a FIB and a name, ZERO return accepts.
  362.     BITDEF    FR,DoMsgFunc,6    ; You get all IDCMP message not for FileRequest()
  363.     BITDEF    FR,DoColor,5    ; Set this bit for that new and differnt look
  364.     BITDEF    FR,NewIDCMP,4    ; Force a new IDCMP (only if fr_Window != NULL)
  365.     BITDEF    FR,NewWindFunc,3 ; You get to modify the NewWindow struct.
  366.     BITDEF    FR,AddGadFunc,2 ; You get to add gadgets
  367.     BITDEF    FR,GEventFunc,1 ; Function to call if one of your gads is selected
  368.     BITDEF    FR,ListFunc,0    ; not implemented.
  369.  
  370. FCHARS    EQU    32            ; Directory name sizes
  371. DSIZE    EQU    33
  372.  
  373. * The bits FR2Bxxx are in the fr_reserved1 byte.
  374.     BITDEF    FR2,LongPath,0    ; Specify that fr_Dir buffer is 256
  375.                 ;  bytes long
  376. LONG_DSIZE    EQU    254    ; If FRB_LongPath, you must allocate
  377.                 ; LONG_DSIZE+1 rather than DSIZE+1 for
  378.                 ; fr_Dir buffer
  379. LONG_FSIZE    EQU    126
  380.  
  381. FR_FIRST_GADGET EQU    $7680        ; User gadgetID's must be less than this.
  382. ************************************************************************
  383. ************************ PATTERN MATCHING ******************************
  384. ************************************************************************
  385.  
  386. * structure expected by FindFirst, FindNext.
  387. * Allocate this structure and initialize it as follows:
  388. *
  389. * Set ap_BreakBits to the signal bits (CDEF) that you want to take a
  390. * break on, or NULL, if you don't want to convenience the user.
  391. *
  392. * If you want to have the FULL PATH NAME of the files you found,
  393. * allocate a buffer at the END of this structure, and put the size of
  394. * it into ap_Length.  If you don't want the full path name, make sure
  395. * you set ap_Length to zero.  In this case, the name of the file, and stats
  396. * are available in the ap_Info, as per usual.
  397. *
  398. * Then call FindFirst() and then afterwards, FindNext() with this structure.
  399. * You should check the return value each time (see below) and take the
  400. * appropriate action, ultimately calling FreeAnchorChain() when there are
  401. * no more files and you are done.  You can tell when you are done by
  402. * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
  403. *
  404.  
  405.     STRUCTURE AnchorPath,0
  406.         LABEL    ap_First
  407.         CPTR    ap_Base     ; pointer to first anchor
  408.         LABEL    ap_Current
  409.         CPTR    ap_Last     ; pointer to last anchor
  410.         LONG    ap_BreakBits    ; Bits we want to break on
  411.         LONG    ap_FoundBreak    ; Bits we broke on. Also returns ERROR_BREAK
  412.         LABEL    ap_Length    ; Old compatability for LONGWORD ap_Length
  413.         BYTE    ap_Flags    ; New use for extra word.
  414.         BYTE    ap_Reservred
  415.         WORD    ap_Strlen    ; This is what ap_Length used to be
  416.         STRUCT    ap_Info,fib_SIZEOF    ; FileInfoBlock
  417.         LABEL    ap_Buf        ; Buffer for path name, allocated by user
  418.         LABEL    ap_SIZEOF
  419.  
  420.  
  421.     BITDEF    AP,DOWILD,0        ; User option ALL
  422.     BITDEF    AP,ITSWILD,1        ; Set by FindFirst, used by FindNext
  423.                     ; Application can test APB_ITSWILD, too.
  424.     BITDEF    AP,DODIR,2        ; Bit is SET if a DIR node should be
  425.                     ; entered. Application can RESET this
  426.                     ; bit after FindFirst/FindNext to AVOID
  427.                     ; entering a dir.
  428.     BITDEF    AP,DIDDIR,3        ; Bit is SET for an "expired" dir node.
  429.     BITDEF    AP,NOMEMERR,4        ; Set on memory error
  430.     BITDEF    AP,DODOT,5        ; If set, allow conversion of '.' to CurrentDir
  431.  
  432.     STRUCTURE    AChain,0
  433.         CPTR    an_Child
  434.         CPTR    an_Parent
  435.         LONG    an_Lock
  436.         STRUCT    an_Info,fib_SIZEOF    ; FileInfoBlock
  437.         BYTE    an_Flags
  438.         LABEL    an_String
  439.         LABEL    an_SIZEOF
  440.  
  441.     BITDEF    DD,PatternBit,0
  442.     BITDEF    DD,ExaminedBit,1
  443.     BITDEF    DD,Completed,2
  444.     BITDEF    DD,AllBit,3
  445.  
  446.  
  447. * Constants used by wildcard routines, these are the pre-parsed tokens
  448. * referred to by pattern match.  It is not necessary for you to do
  449. * anything about these, FindFirst() FindNext() handle all these for you.
  450.  
  451. P_ANY        EQU    $80    ; Token for '*' or '#?
  452. P_SINGLE    EQU    $81    ; Token for '?'
  453. P_ORSTART    EQU    $82    ; Token for '('
  454. P_ORNEXT    EQU    $83    ; Token for '|'
  455. P_OREND     EQU    $84    ; Token for ')'
  456. P_TAG        EQU    $85    ; Token for '{'
  457. P_TAGEND    EQU    $86    ; Token for '}'
  458. P_NOTCLASS    EQU    $87    ; Token for '^'
  459. P_CLASS     EQU    $88    ; Token for '[]'
  460. P_REPBEG    EQU    $89    ; Token for '['
  461. P_REPEND    EQU    $8A    ; Token for ']'
  462.  
  463. * Values for an_Status, NOTE: These are the actual bit numbers
  464.  
  465. COMPLEX_BIT    EQU    1    ; Parsing complex pattern
  466. EXAMINE_BIT    EQU    2    ; Searching directory
  467.  
  468. * Returns from FindFirst(), FindNext()
  469. * You can also get dos error returns, such as ERROR_NO_MORE_ENTRIES,
  470. * these are in the dos.h file.
  471. *
  472. ERROR_BUFFER_OVERFLOW    EQU    303    ; User or internal buffer overflow
  473. ERROR_BREAK        EQU    304    ; A break character was received
  474. ERROR_NOT_EXECUTABLE    EQU    305    ; A file has E bit cleared
  475.  
  476.  
  477. * Structure used by AddDANode, AddDADevs, FreeDAList
  478. *
  479. * This structure is used to create lists of names,
  480. * which normally are devices, assigns, volumes, files, or directories.
  481.  
  482.     STRUCTURE DirectoryEntry,0
  483.         CPTR    de_Next         ; Next in list
  484.         BYTE    de_Type         ; DLX_mumble
  485.         BYTE    de_Flags        ; For future expansion, do not use!
  486.         LABEL    de_Name         ; name of thing found
  487.         LABEL    de_SIZEOF
  488.  
  489. * Defines you use to get a list of the devices you want to look at.
  490. * For example, to get a list of all directories and volumes, do
  491. *
  492. *    move.l    #DLF_DIRS!DLF_VOLUMES,d0
  493. *    move.l    myDalist(pc),a0
  494. *    SYSCALL AddDADevs        ; ArpBase already in A6, of course
  495. *
  496. * After this, you can examine the de_Type field of the elements added
  497. * to your list (if any) to discover specifics about the objects added.
  498. *
  499. * Note that if you want only devices which are also disks, you must
  500. * request DLF_DEVICES!DLF_DISKONLY
  501. *
  502.  
  503.     BITDEF    DL,DEVICES,0    ; Return devices
  504.     BITDEF    DL,DISKONLY,1    ; Modifier for above: Return disk devices only
  505.     BITDEF    DL,VOLUMES,2    ; Return volumes only
  506.     BITDEF    DL,DIRS,3    ; Return assigned devices only
  507.  
  508. * Legal de_Type values, check for these after a call to AddDADevs(), or
  509. * use on your own as the ID values in AddDANode()
  510.  
  511. DLX_FILE    EQU    0    ; AddDADevs() can't determine this
  512. DLX_DIR     EQU    8    ; AddDADevs() can't determine this
  513. DLX_DEVICE    EQU    16    ; It's a resident device
  514.  
  515. DLX_VOLUME    EQU    24    ; Device is a volume
  516. DLX_UNMOUNTED    EQU    32    ; Device is not resident
  517.  
  518. DLX_ASSIGN    EQU    40    ; Device is a logical assignment
  519.  
  520. ************************************************************************
  521. ************************** RESOURCE TRACKING ***************************
  522. ************************************************************************
  523.  
  524. *
  525. * NOTE: This is a DosAllocMem'd list, this is done for you when you
  526. * call CreateTaskResList(), typically, you won't need to access/allocate
  527. * this structure.
  528. *
  529.     STRUCTURE ResList,0
  530.         STRUCT    rl_Node,MLN_SIZE  ; Used by arplib to link reslist's
  531.         CPTR    rl_TaskID       ; Owner of this list
  532.         STRUCT    rl_FirstItem,MLH_SIZE    ; List of TrackedResource's
  533.         CPTR    rl_Link     ; For temp removal from task rlist
  534.         LABEL    RL_SIZEOF
  535.  
  536. * The rl_FirstItem list (above) is a list of TrackedResource (below).
  537. * It is very important that nothing in this list depend on the task
  538. * existing at resource freeing time (i.e., RemTask(0L) type stuff,
  539. * DeletePort() and the rest).
  540. *
  541. * The tracking functions return a struct Tracker *Tracker to you, this
  542. * is a pointer to whatever follows the tr_ID variable.
  543. * The default case is reflected below, and you get it if you call
  544. * GetTracker() ( see DefaultTracker below).
  545. *
  546. * NOTE: The two user variables mentioned in an earlier version don't
  547. * exist, and never did. Sorry about that (SDB).
  548. *
  549. * However, you can still use ArpAlloc to allocate your own tracking
  550. * nodes and they can be any size or shape you like, as long as the
  551. * base structure is preserved.    They will be freed automagically
  552. * just like the default trackers.
  553.  
  554.     STRUCTURE TrackedResource,0
  555.         STRUCT    tr_Node,MLN_SIZE    ; Double linked pointer
  556.         BYTE    tr_Flags        ; Don't touch
  557.         BYTE    tr_Lock         ; Don't touch, for Get/FreeAcess
  558.         SHORT    tr_ID            ; ID for this item class
  559. * The struct DefaultTrackter portion of the structure
  560. * The stuff below this point can conceivably vary, depending
  561. * on user needs, etc.  This reflects the default.
  562.         UNION    tr_Object,4        ; The thing being tracked
  563.             UMEMB tr_Object_tg_Verify    ; for use during TRAK_GENERIC
  564.             UMEMB tr_Object_tr_Resource ; whatever
  565.         UNION    tr_Extra,4        ; only needed sometimes
  566.             UMEMB tr_Extra_tg_Function    ; function to call for TRAK_GENERIC
  567.             UMEMB tr_Extra_tr_Window2    ; for TRAK_WINDOW
  568.         LABEL    trk_SIZEOF        ; trk_ fixes COLLISION WITH TMPRAS...
  569.  
  570. tr_Object_tg_Value EQU tr_Object_tg_Verify
  571.  
  572. * You get a pointer to a struct of the following type when you call
  573. * GetTracker().  You can change this, and use ArpAlloc() instead of
  574. * GetTracker() to do tracking. Of course, you have to take a wee bit
  575. * more responsibility if you do, as well as if you use TRAK_GENERIC
  576. * stuff.
  577. *
  578. * TRAK_GENERIC folks need to set up a task function to be called when an
  579. * item is freed.  Some care is required to set this up properly.
  580. *
  581. * Some special cases are indicated by the unions below, for TRAK_WINDOW,
  582. * if you have more than one window opened, and don't want the IDCMP closed
  583. * particularly, you need to set a ptr to the other window in dt_Window2.
  584. * See CloseWindowSafely() for more info.  If only one window, set this to NULL.
  585.  
  586.     STRUCTURE DefaultTracker,-2
  587.         SHORT    dt_ID        ; Different from C file, but it's ok.
  588.         UNION    dt_Object,4    ; the object being tracked
  589.             UMEMB dt_Resource    ; Whatever
  590.             UMEMB tg_Verify    ; whatever
  591.         UNION    dt_Extra,4
  592.             UMEMB tg_Function    ; function to call for TRAK_GENERIC
  593.             UMEMB dt_Window2
  594.         LABEL    dt_SIZEOF
  595.  
  596. tg_Value EQU tg_Verify    ; ancient compatibility
  597. * Tracked Item Types
  598. *    The id types below show the types of resources which may
  599. * be tracked in a resource list.
  600. *
  601. TRAK_AAMEM    EQU    0        ; Default generic (ArpAlloc) element
  602. TRAK_LOCK    EQU    1        ; File Lock
  603. TRAK_FILE    EQU    2        ; Opened File
  604. TRAK_WINDOW    EQU    3        ; Window (see discussion)
  605. TRAK_SCREEN    EQU    4        ; Screen
  606. TRAK_LIBRARY    EQU    5        ; Opened library
  607. TRAK_DAMEM    EQU    6        ; Pointer to DosAllocMem block
  608. TRAK_MEMNODE    EQU    7        ; AllocEntry() node.
  609. TRAK_SEGLIST    EQU    8        ; Program Segment List
  610. TRAK_RESLIST    EQU    9        ; ARP (nested) ResList
  611. TRAK_MEM    EQU    10        ; Memory ptr/length
  612. TRAK_GENERIC    EQU    11        ; Generic Element
  613. TRAK_DALIST    EQU    12        ; DAlist ( as used by file request )
  614. TRAK_ANCHOR    EQU    13        ; Anchor chain
  615. TRAK_FREQ    EQU    14        ; FileRequest struct
  616. TRAK_FONT    EQU    15        ; GfxBase CloseFont()
  617. TRACK_MAX    EQU    15        ; Anything else is tossed.
  618.  
  619.     BITDEF    TR,UNLINK,7        ; Bit for freeing the node
  620.     BITDEF    TR,RELOC,6        ; This element may be relocated (not used yet
  621.     BITDEF    TR,MOVED,5        ; Item moved
  622.  
  623. *--- Returns from CompareLock()
  624.  
  625. LCK_EQUAL    EQU    0    ; Locks refer to the same object
  626. LCK_VOLUME    EQU    1    ; Locks are on the same volume
  627. LCK_DIFVOL1    EQU    2    ; Locks are on different volumes
  628. LCK_DIFVOL2    EQU    3    ; Locks are on different volumes
  629.  
  630. *----------- Stuff For ASyncRun() and friends
  631. *---------- Message sent back on request by an exiting process.
  632. *---------- You request this by putting the address of your
  633. *---------- message in pcb_LastGasp, and initializing the
  634. *---------- ReplyPort variable of the zombiemsg to the port you wish
  635. *---------- the message posted to.
  636.  
  637.     STRUCTURE ZombieMsg,MN_SIZE
  638.         ULONG    zm_TaskNum        ; task ID
  639.         ULONG    zm_ReturnCode        ; Process's return code 
  640.         ULONG    zm_Result2        ; System return
  641.         STRUCT    zm_ExitTime,ds_SIZEOF    ; Date stamp at time of exit
  642.         ULONG    zm_UserInfo        ; for whatever you like
  643.         LABEL    zm_SIZEOF
  644.         
  645. *------------ Structure required by ASyncRun() -- see docs for more info.
  646. *------------
  647.     STRUCTURE ProcessControlBlock,0
  648.         ULONG    pcb_StackSize    ; Stacksize for new process
  649.         BYTE    pcb_Pri     ; Priority of new process
  650.         BYTE    pcb_Control    ; Control bits, see BITDEF's below.
  651.         APTR    pcb_TrapCode    ; Optional trapcode vector
  652.         ULONG    pcb_Input    ; Optional default input
  653.         ULONG    pcb_Output    ; Optional default output
  654.         UNION    pcb_Console,4
  655.             UMEMB pcb_SplatFile ; file to use for Open("*")
  656.             UMEMB pcb_ConName    ; CON: filename 
  657.         ULONG    pcb_LoadedCode    ; If not null, use this code
  658.         CPTR    pcb_LastGasp    ; ReplyMsg to be filled in by exit code
  659.         CPTR    pcb_WBProcess    ; Valid only when PRB_NOCLI.
  660.         LABEL    pcb_SIZEOF
  661.  
  662. *---- bits to set in pcb_Control
  663.  
  664.     BITDEF    PR,SAVEIO,0        ; don't release/check file handles
  665.     BITDEF    PR,CLOSESPLAT,1     ; close splat, must request explicitly
  666.     BITDEF    PR,NOCLI,2        ; Don't want a CLI
  667.     BITDEF    PR,CODE,4        ; Actual code address. Be Careful!
  668.     BITDEF    PR,STDIO,5        ; Do the stdio thing, splat = CON:filename
  669.  
  670.  
  671. *----- Error returns
  672.  
  673. PR_NOFILE    EQU    -1    ; Can't find or LoadSeg file.
  674. PR_NOMEM    EQU    -2    ; No memory for one thing or another
  675. PR_NOSLOT    EQU    -4    ; No slot in task array
  676. PR_NOINPUT    EQU    -5    ; Can't get input file
  677. PR_NOOUTPUT    EQU    -6    ; Can't get output file
  678. PR_NOSTDIO    EQU    -11    ; Couldn't get stdio handles.
  679.  
  680. *---- The following error returns are obsolete in versions 35+
  681. *---- will not be returned.
  682. PR_NOCLI    EQU    -3    ; Caller must be CLI (SyncRun() only).
  683. PR_NOLOCK    EQU    -7    ; Problem obtaining locks
  684. PR_ARGERR    EQU    -8    ; Bad Argument
  685. PR_NOBCPL    EQU    -9    ; Bad program passed to ASyncRun
  686. PR_BADLIB    EQU    -10    ; Bad library version
  687. *
  688. * Version 35 adds the following error messages.
  689. *
  690. PR_WANTSMESSAGE EQU    -12    ; Child wants you to report IoErr() to user.
  691. PR_NOSHELLPROC    EQU    -13    ; Can't create a shell/cli process
  692. *
  693. PR_NOEXEC    EQU    -14
  694. PR_SCRIPT    EQU    -15
  695.  
  696. * Version 35 ASyncRun () allows you to create an independent interactive or
  697. * background Shell/CLI. You need this variant of the pcb structure to
  698. * do it, and you also have new values for nsh_Control, see below.
  699. *
  700. * Syntax for Interactive shell is:
  701. *
  702. * rc = ASyncRun ("Optional Window Name", "Optional From File", &NewShell);
  703. *
  704. * Syntax for a background shell is:
  705. * rc = ASyncRun ("Command line", 0L, &NewShell);
  706. *
  707. * Same syntax for an Execute style call, but you have to be on drugs
  708. * if you want to do that.
  709. *
  710.     STRUCTURE NewShell,0
  711.     ULONG nsh_StackSize     ; stacksize shell will use for children
  712.     BYTE  nsh_Pri         ; ignored by interactive shells
  713.     UBYTE nsh_Control     ; bits/values: see above
  714.     CPTR  nsh_LogMsg     ; Optional login message, if null, use default.
  715.     CPTR  nsh_Input      ; ignored by interactive shells, but
  716.     CPTR  nsh_Output     ; used by background and execute options.
  717.     STRUCT nsh_RESERVED,(5*4)
  718.     LABEL nsh_SIZEOF
  719.  
  720. *-- Bit Values for nsh_Control, you should use them as shown below, or
  721. *-- just use the actual values indicated: the bits don't really combine
  722. *-- otherwise.
  723.  
  724.     BITDEF    PR,FB,7     ; alt function bit
  725.     BITDEF    PR,CLI,0    ; Do a CLI, not a shell.
  726.     BITDEF    PR,BACKGROUND,1 ; Background shell.
  727.     BITDEF    PR,EXECUTE,2    ; Do as for Execute
  728.     BITDEF    PR,INTERACTIVE,3 ; run an interactive shell        
  729. *-- Actual values to stuff into nsh_Control.
  730.  
  731. INTERACTIVE_SHELL EQU (PRF_FB!PRF_INTERACTIVE)    ; Gimme a newshell!
  732. INTERACTIVE_CLI  EQU (PRF_FB!PRF_INTERACTIVE!PRF_CLI) ; Gimme that ol newcli!
  733. BACKGROUND_SHELL EQU (PRF_FB!PRF_BACKGROUND) ; gimme a background shell
  734. EXECUTE_ME     EQU (PRF_FB!PRF_BACKGROUND!PRF_EXECUTE) ; aptly named, doncha think?
  735.  
  736.     IFND ERROR_BAD_STREAM_NAME
  737. ERROR_BAD_STREAM_NAME    EQU    206 ; not defined in dos.i - imagine that.
  738.    ENDC
  739.  
  740. *---------- Programs should return this as result2 if no CLI:
  741.  
  742. ERROR_NOT_CLI    EQU    400    ; Program/function needed a CLI
  743.  
  744. *-------------------------------- Resident Program support -------*
  745. *--- This node is allocated for you when you AddResidentPrg() a segment.
  746. *--- They are stored as a single linked list with the root in ArpBase,
  747. *--- if you absolutely *must* wander through this list instead of
  748. *--- using the supplied functions, then you must first obtain the
  749. *--- the semaphore which protects this list, and then release it afterwards.
  750. *--- Do not use Forbid() and Permit() to gain exclusive access!
  751. *------------------------------------------------------------------*
  752.  
  753.         STRUCTURE ResidentProgramNode,0
  754.                 CPTR    rpn_Next        ; next node, or NULL
  755.                 WORD    rpn_Usage       ; current number of simultaneous users
  756.                 UWORD   rpn_AccessCnt   ; total times used
  757.                 ULONG   rpn_CheckSum    ; checksum for this code
  758.                 BPTR    rpn_Segment     ; the segment
  759.         UWORD    rpn_Flags    ; See flag bit definitions below.
  760.                 LABEL   rpn_Name        ; the name of the program.
  761.                 LABEL   rpn_SIZEOF
  762.  
  763.     BITDEF    RPN,NOCHECK,0        ; Set in rpn_Flags for no checksumming.
  764.     BITDEF    RPN,CACHE,1        ; Private usage in V1.3.
  765.  
  766. *--- If your program starts with this structure, ASyncRun() and SyncRun()
  767. *--- will override a users stack request with the value in rpt_StackSize.
  768. *--- Furthermore, if you are actually attached to the resident list,
  769. *--- a memory block of size rpt_DataSize will be allocated for you, and
  770. *--- a pointer to this data passed to you in register A4.  You may use this
  771. *--- block to clone the data segment of programs, thus resulting in
  772. *--- one copy of text, but multiple copies of data/bss for each process
  773. *--- invocation.  If you are resident, your program will start at rpt_Instruction,
  774. *--- otherwise, it will be launched from the initial branch.
  775.  
  776.  
  777.     STRUCTURE    ResidentProgramTag,0
  778.         BPTR    rpt_NextSeg    ; provided by DOS at LoadSeg time.
  779.         UWORD    rpt_BRA     ; Short branch to executable
  780.         UWORD    rpt_Magic    ; resident majik value
  781.         ULONG    rpt_StackSize    ; min stack for this process
  782.         ULONG    rpt_DataSize    ; Size of data allocation (may be zero)
  783.         LABEL    rpt_Instruction ; start here if resident
  784.  
  785. ************* The form of the ARP allocated node in your tasks memlist when
  786. ************* launched as a resident program, note that the data portion
  787. ************* of the node will only exist if you have specified a nonzero
  788. ************* value for rpt_DataSize. Note also that this structure is READ ONLY,
  789. ************* modify values in this at your own risk. The stack stuff is for
  790. ************* tracking, if you need actual addresses or stacksize, check the
  791. ************* normal places for it in your process/task structure.
  792.  
  793.     STRUCTURE ProcessMemory,LN_SIZE
  794.         UWORD    pm_Num        ; number of entries, 1 if no data 2 if data
  795.         CPTR    pm_Stack
  796.         ULONG    pm_StackSize
  797.         CPTR    pm_Data     ; pointer to data
  798.         ULONG    pm_DataSize
  799.         LABEL    pm_Sizeof
  800. * Search for the name below on your TC_MEMENTRY list if you need to
  801. * get the above node.  Remember, you modify the above at your own
  802. * risk!
  803. *
  804. PMEM_NAME    MACRO
  805.     dc.b    'ARP_PMEM',0    ; memlist node for stack and/or data
  806.     ds.w    0
  807.     ENDM
  808.  
  809. RESIDENT_MAGIC        EQU    $4AFC        ; same as RTC_MATCHWORD (trapf)
  810.  
  811. ********** Note that the initial branch and the rpt_Instruction do not
  812. ********** have to be the same.  This allows different actions to be taken
  813. ********** if you are diskloaded or resident.  DataSize memory will be allocated
  814. ********** only if you are resident, but stacksize will override all user
  815. ********** stack requests.
  816. **********
  817. ********** Macro to facilitate initialization of this structure, place at start
  818. ********** of code.
  819. ********** Usage is RESIDENT STACKSIZE [ optional  DATASIZE LABEL ]
  820.  
  821. RESIDENT MACRO
  822.  IFEQ NARG
  823.     FAIL
  824.  ENDC
  825.  IFC '\3',''
  826.     bra.s    resident_start\@    ; branch to rp_instruction
  827.  ENDC
  828.  IFNC '\3',''
  829.     bra.s    \3        ; branch to user label
  830.  ENDC
  831.     dc.w    RESIDENT_MAGIC        ; our magic value
  832.     dc.l    \1            ; stacksize
  833.  IFNC '\2',''
  834.     dc.l    \2            ; datasize
  835.  ENDC
  836.  IFC '\2',''
  837.     dc.l    0            ; of zero
  838.  ENDC
  839. resident_start\@
  840.     ENDM
  841.  
  842. *--------- String/Date structures etc
  843.     STRUCTURE    DateTime,0
  844.     STRUCT    dat_Stamp,ds_SIZEOF    ;DOS DateStamp
  845.     UBYTE    dat_Format        ;controls appearance of dat_StrDate
  846.     UBYTE    dat_Flags        ;see BITDEF's below
  847.     CPTR    dat_StrDay        ;day of the week string
  848.     CPTR    dat_StrDate        ;date string
  849.     CPTR    dat_StrTime        ;time string
  850.     LABEL    dat_SIZEOF
  851. *
  852. * You need this much room for each of the DateTime strings:
  853. LEN_DATSTRING    EQU    10
  854.  
  855. *    flags for dat_Flags
  856. *
  857.     BITDEF    DT,SUBST,0        ;substitute Today, Tomorrow, etc.
  858.     BITDEF    DT,FUTURE,1        ;day of the week is in future
  859. *
  860. *    date format values
  861. *
  862. FORMAT_DOS    equ    0
  863. FORMAT_INT    equ    1
  864. FORMAT_USA    equ    2
  865. FORMAT_CDN    equ    3
  866. FORMAT_MAX    equ    FORMAT_CDN
  867.  
  868. *---------- handy macros
  869.  
  870. LINKEXE MACRO
  871.     LINKLIB _LVO\1,4
  872.     ENDM
  873.  
  874. * LINKDOS now uses ArpBase
  875. * CALLDOS was nuked, to reduce confusion
  876.  
  877. LINKDOS MACRO
  878.     jsr    _LVO\1(a6)
  879.     ENDM
  880.  
  881.  
  882. CALLEXE MACRO
  883.     move.l    4,a6
  884.     jsr    _LVO\1(a6)
  885.     ENDM
  886.  
  887. * SYSCALL re-revised for only one arg
  888. *    DosBase should always use ArpBase, or DosBase, in A6
  889.  
  890. SYSCALL MACRO
  891.     jsr    _LVO\1(A6)
  892.     ENDM
  893.  
  894. * Use this macro if arp.library can't be found.
  895. *    Note the assumption that stack is offset by 8 from return addr.
  896. *    After the macro, register A6 is ARPBASE
  897. *
  898.  
  899. * Use this macro to open arp.library and avoid recoverable alerts.
  900. * Saves D0/A0 on stack.
  901. * After executing, A6 = ARPBASE and stack points at D0/A0
  902. *
  903. OPENARP MACRO
  904.     IFC    '\1',''
  905.     RESIDENT    4000,0
  906.     ENDC
  907.     movem.l d0/a0,-(sp)
  908.     move.l    4,A6
  909.     lea.l    ARPNAME(pc),a1        ; Get ArpBase
  910.     moveq.l #ArpVersion,d0
  911.     SYSCALL OpenLibrary
  912.     tst.l    d0
  913.     bne.s    okgo
  914.     lea    dname,A1
  915.     SYSCALL OpenLibrary
  916.     tst.l    D0
  917.     beq.s    1$
  918.     move.l    D0,A6
  919.     SYSCALL Output            ;standard output file handle
  920.     move.l    d0,d1
  921.     beq.s    1$            ; No output. Phoey.
  922.     lea.l    alibmsg(pc),a0        ;tell user he needs to find library
  923.     move.l    a0,d2
  924. aliblng    equ    28            ; SEE BELOW
  925.     moveq.l    #aliblng,d3
  926.     SYSCALL Write
  927. 1$:    addq    #8,sp
  928.     rts
  929.  
  930.     IFGE ArpVersion-100
  931.      FAIL "You lose: Time to bump version report to 3 digits!"
  932.     ENDC
  933.  
  934. TEM    SET    ArpVersion/10
  935. dname    dc.b    'dos.library',0
  936. alibmsg dc.b    'you need '
  937. ARPNAME: ArpName
  938.     dc.b    ' V',TEM+'0',(ArpVersion-(TEM*10))+'0','+',10
  939.     ds.w    0
  940. okgo:    move.l    D0,A6
  941.     ENDM
  942.  
  943.  
  944. ***       INCLUDE "libraries/arpcompat.i"
  945.  
  946.     ENDC    !LIBRARIES_ARPBASE_I
  947.  
  948. *Local Variables:
  949. *mode:indented-text
  950. *eval:(setq last-change-log "arpheaders.log")
  951. *End:
  952.  
  953.